package com.hh.generator.core.generator;

import com.hh.generator.core.model.MethodModel;
import org.apache.commons.lang.StringUtils;

public class MethodGenerator extends AbstractGenerator {

    private static String templateName = "Method.vm";

    private String type;

    private String methodName;
    private String requestClassName;
    private String responseClassName;

    public MethodGenerator(String type, String entity, String action) {
        this.type = type;
        this.methodName = StringUtils.uncapitalize(action) + StringUtils.capitalize(entity);
        this.requestClassName = StringUtils.capitalize(entity) + StringUtils.capitalize(action) + "Request";
        this.responseClassName = StringUtils.capitalize(entity) + StringUtils.capitalize(action) + "Response";
    }

    public String generatorMethod(String clazzType) {
        MethodModel model = new MethodModel();
        model.setType(clazzType + "." + type);
        model.setRequestClassName(requestClassName);
        model.setMethodName(methodName);
        model.setResponseClassName(responseClassName);
        return doGenerate(model, templateName);
    }

}
